<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="geometry" content="facet">
  <link rel="stylesheet" href="./assets/common.css">
  <title>Facets Point Plot</title>
</head>

<body>
  <div id="canvas"></div>
  <script src="./assets/jquery-3.2.1.min.js"></script>
  <script src="../build/g2.js"></script>
  <script>
    $.getJSON('./data/diamond.json', data => {
      const chart = new G2.Chart({
        container: 'canvas',
        forceFit: true,
        height: window.innerHeight,
        padding: 'auto'
      });

      chart.source(data, {
        carat: {
          sync: true
        },
        price: {
          sync: true
        },
        cut: {
          sync: true
        }
      });
      chart.facet('rect', {
        fields: [ 'cut', 'clarity' ],
        eachView(view) {
          view.point().position('carat*price').color('cut');
        }
      });
      chart.render();
    });
  </script>
</body>
</html>